import * as React from "react";
import { useAppSelector } from "../store/hook";
import { Navigate } from "react-router-dom";
export interface IRequireAuthProps {
  children: React.ReactNode;
}

export default function RequireAuth(props: IRequireAuthProps) {
  const { userInfo } = useAppSelector((state) => state.user);
  return <div>{userInfo ? props.children : <Navigate to="/login" />}</div>;
}
